package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author fenge
 */
@Controller
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @PostMapping("list")
    @ResponseBody
    public Map<String,Object> list(Integer page, Integer rows, String  customerName){
        return customerService.list(page,rows,customerName);
    }

    @PostMapping("save")
    @ResponseBody
    public ServiceVO save(Customer customer){
        customerService.save(customer);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("delete")
    @ResponseBody
    public ServiceVO delete(String ids){
        customerService.delete(ids);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("getComboboxList")
    @ResponseBody
    public List<Customer> getComboboxList(String q){
        return customerService.getComboboxList(q);
    }
}
